<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/10/17
 * Time: 9:42
 */
namespace Home\Controller;

use Think\Controller;

class LoginController extends Controller {

    public function login(){

        $this->display();

    }

    public function checklogin(){

        if (!IS_AJAX){
            $this->error('提交方式不正确',0,0);
        }
        $info['ComLoginID']= I('userInfo');
        $info['ComPwd'] = I('userPsd');
        $obj = D('B2c');

        $res = $obj->table('tb_company')->where(array('ComLoginID'=>$info['ComLoginID']))->find();

        if (!$res){
            $data = [
                'message'=>'账号不存在',
                'state' => false
            ];
            $this->ajaxReturn($data);
        }

        if ($res['compwd'] != $info['ComPwd'] ){
            $data = [
                'message'=>'密码错误',
                'state' => false
            ];
            $this->ajaxReturn($data);
        }else{
            $_SESSION['c_user'] = $info['ComLoginID'];
            $_SESSION['comid'] = $res['comid'];
            $data = [
                'message'=>'登录成功',
                'state' => true
            ];
            $this->ajaxReturn($data);
        }



    }

}